{% extends "base.html" %}
{% block content %}
    <script type="text/javascript" language="javascript">
        function MakeTaskDone(id) {
            $.ajax({
                type: "POST",
                url: "/api/task/done",
                data: "tid=" + id + "&tids=true"
            }).done(function() {
                        $("#task_" + id).animate({opacity: 0, height: 0}, 510, function() {$(this).remove();});
                    });
        }
    </script>
    {% if task_list %}
        <div class="tasks_list">
            {% for task in task_list %}
                <div id="task_{{ task.id }}" class='task task-in-list'>
                    <div class="task-top">
                        <div class='task-subject'>
                            {{ task.subject }}
                        </div>
                        <div class='task-date'>
                            с
                            {{ task.from_date }}
                            на
                            {{ task.to_date }}
                        </div>
                    </div>
                    <a href="/task/{{ task.id }}">
                        {% if task.title %}
                            <div class='task-title'>
                                {{ task.title|linebreaks }}
                            </div>
                        {% else %}
                            <div class='task-text'>
                                {{ task.text|linebreaks }}
                            </div>
                        {% endif %}
                    </a>
                    <div class="task_make_done">
                        <a href="#" onclick="MakeTaskDone({{ task.id }}); return false;">Сделано!</a>
                    </div>
                    <div class='task-author'>
                        {{ task.author.username }}
                    </div>
                    {% if task.task_type %}
                        <div class='task-type'>
                            {{ task.task_type }}
                        </div>
                    {% endif %}
                </div>
            {% endfor %}
        </div>
    {% else %}
        <div class='no-tasks'>
            Ничего не задано
        </div>
    {% endif %}
{% endblock %}
